package com.itcast.demo;

import java.io.IOException;

import org.csource.common.MyException;
import org.csource.fastdfs.ClientGlobal;
import org.csource.fastdfs.StorageClient;
import org.csource.fastdfs.StorageServer;
import org.csource.fastdfs.TrackerClient;
import org.csource.fastdfs.TrackerServer;

public class TestFdfs {

	public static void main(String[] args) throws IOException, MyException {
		// 1.加载配置文件
		ClientGlobal.init("E:\\git\\gitee\\demo\\fastDFS-demo\\src\\main\\resources\\fdfs_client.conf");
		// 2.创建一个管理者客户端
		TrackerClient client = new TrackerClient();
		// 3.连接管理者服务端
		TrackerServer trackerServer = client.getConnection();
		// 4.声明存储服务端
		StorageServer storageServer = null;
		// 5.获取存储客户端对象
		StorageClient storageClient = new StorageClient(trackerServer, storageServer);
		// 6.上传文件
		String[] strs = storageClient.upload_file("E:\\images\\banner3.jpg", "jpg", null);
		// 7.显示上传结果file_id
		for (String str : strs) {
			System.out.println(str);
		}
	}
}
